<template>
  <div>
     <appdialog 
			ref="dialog"
			:visible="false" 
			title="配置文件"
			@confirm="confirmAdd"
			@cancle="cancleAdd"
			width="50%"
			>
      <div v-loading="loading">
        <el-input type="textarea" rows="15" v-model="content"></el-input>
      </div>
		</appdialog>
  </div>
</template>


<script>
import appdialog from "@/view/components/dialog/dialog";
import {getFileContent,createFile} from '@/service/swagger/FileController.js'
  export default{
    props:[
    	
    ],
    components:{
     appdialog
    },
    data(){
      return{
        loading:false,
        content:'',
        filePath : '',
        fileName : ''
      }
    },
    mounted() {
    },
    methods:{
    	init(options){
    		this.filePath = options.filePath ;
    		this.fileName = options.fileName ;
    		this.getFileData()
    	},
    	getFileData(){
        this.loading = true
    		getFileContent({filePath:this.filePath}).then(ret=>{
        this.loading = false
          if(ret&&ret.code == 0){
            this.content = ret.data
          }
        })
    	},
      open() {
        this.content = ''
        this.$refs.dialog.open();
        return this;
      },
      close(){
        this.$refs.dialog.close();
        return this;
      },
      confirmAdd() {
        createFile({filePath:this.filePath,fileName:this.fileName,content:this.content}).then(ret=>{
          if(ret&&ret.code == 0){
          	this.$emit("editSucess", "updateFileDialog" , ret.data)
            this.$message({message: '修改成功',type: 'success'})
          }else{
            this.$message({message: '修改失败',type: 'error'})
          }
        })
        this.close();
      },
      cancleAdd() {}
    }
  }
</script>



<style>

</style>
